<template>
	<view>
		<view class="goods-item" @click="gotodetail">
			<view class="goods-left">
				<radio  color="#c00000" v-show="isshow" :checked="goods.goods_state" @click="radioClickhandler"></radio>
				<image :src="goods.goods_small_logo || defaultPic" class="goods-pic" mode="widthFix" :style="{width:goods.goods_weight+'px'}"></image>
			</view>
			<view class="goods-right">
				<view class="goods-right-title">
					{{goods.goods_name}}
				</view>
				<view class="goods-right-price">
					<view class="goodprices">
						￥{{goods.goods_price|monery}}
					</view>
					<block v-if="isshownum">
						<uni-number-box :min="1" :value="goods.goods_count" @change="numchange"></uni-number-box>
					</block>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		
		name:"my-goods",
		props:{
			goods:{
				type:Object,
				default:{}
			},
			isshow:{
				type:Boolean,
				default:false
			},
			isshownum:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				defaultPic:"https://bpic.588ku.com/element_origin_min_pic/19/04/09/80edb3630ab6335394f0a2afdeb9ddb0.jpg"
			};
		},
		filters:{
			monery(old){
				return Number(old).toFixed(2)
			}
		},
		methods:{
			gotodetail(){
				this.$emit('gotodetail', this.goods)
			},
			radioClickhandler(){
				this.$emit('readio-change',{
					goods_id:this.goods.goods_id,
					goods_state:!this.goods.goods_state
				})
			},
			numchange(e){
				this.$emit('num-change',{
					goods_id:this.goods.goods_id,
					goodS_count:e-0
				})
			}
		}
	}
</script>

<style scoped>
.goods-item{
	padding: 10px;
	display: flex;
	border-bottom: 1px solid #ccc;
}
.goods-right{
	margin-left: 10px;
	display: flex;
	flex: 1;
	font-size: 14px;
	flex-direction: column;
	justify-content: space-between;
}
.goods-right-title{
	height: 76px;
	margin-bottom: 10px;
}
.goods-right-price{
	display: flex;
	justify-content: space-between;
	color: red;
	font-size: 16px;
	align-items: center;
}
.goods-left{
	display: flex;
	align-items: center;
	justify-content:space-between;
}
.goods-pic{
	width: 100px;
}
.goodprices{
	padding-right: 5px;
	box-sizing: border-box;
}
</style>
